package models.application;

import java.util.*;

import javax.persistence.*;

import models.*;
import models.pubobj.AniObjectState;

import play.data.format.Formats;
import play.data.validation.Constraints;
import play.db.ebean.*;

@Entity
public class AniApiParams extends Model {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7963088904812268538L;

	@Id
	public Long id;
	
	@ManyToOne
	public AniApi hostApi;
	
	@ManyToOne
	public AniObjectState state;
	
	public String paramName;
	
	public String paramValue;
	
	public Boolean isRequired;
	
	public String description;
	
	public static Finder<Long, AniApiParams> find = new Finder<Long, AniApiParams>(Long.class, AniApiParams.class);
	
	public static List<AniApiParams> findAll() {
        return find.all();
    }
	
	public static HashMap<String, String> paramsToMap(List<AniApiParams> paramList){
		HashMap<String, String> params = new HashMap<String, String>();
		for(AniApiParams oneParam: paramList){
			params.put(oneParam.paramName, oneParam.paramValue);
		}
		return params;
	}
}
